package com.five.calendar.common.database;

import android.content.Context;
import android.database.Cursor;

/**
 * 基础数据库操作类(所有需要操作数据库的接口需要实现该类)
 * 
 * 类名称：BaseDataProvider
 * 类描述：
 * 修改备注：
 * @version 1.0.0
 *
 */
public class BaseDataProvider {
	
	public static final String SQL_MATH_MAX = "max(%s) as %s ";
	
	public static final String SQL_MIN_MAX = "min(%s) as %s ";
	
	protected Object mLock;
	
	protected BaseDatabaseHelper mDBOpenHelper;
	
	public BaseDataProvider(Context context) {
		mLock = new Object();
	}
	
	public boolean isNewDB() {
		return mDBOpenHelper.isNewDB();
	}
	
	public Cursor rawQuery(String sql, String[] selectionArgs) {
		synchronized (mLock) {
			return mDBOpenHelper.rawQuery(sql, selectionArgs);
		}
	}

	public boolean execSQL(String... sql) {
		synchronized (mLock) {
			return mDBOpenHelper.execSQL(sql);
		}
	}

	public boolean execSQL(Object... sql) {
		synchronized (mLock) {
			return mDBOpenHelper.execSQL(sql);
		}
	}
	
}
